<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>title</title>
  <!--按顺序引入-->
  <script src="https://cdn.staticfile.org/react/16.8.4/umd/react.development.js"></script>
  <script src="https://cdn.staticfile.org/react-dom/16.8.4/umd/react-dom.development.js"></script>
  <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
  <script src="../js/babel.min.js"></script>
  <script src="https://cdn.bootcdn.net/ajax/libs/prop-types/15.8.1/prop-types.js"></script>
  <style>
    body {
      width: 95vw;
      height: 80vh;
      background-color: #2b2b2b;
      color: wheat;
    }
  </style>
</head>
<body>
<div id="app"></div>

<script type="text/babel">
  class Demo extends React.Component {
    myRef = React.createRef()

    render() {
      return (
          <div>
            <button onClick={this.showData}>点击</button>
            <input ref={this.saveInput} onBlur={this.showData2} type="text" placeholder="失去焦点提示数据"/>
            <input onClick={this.showData3} type="text" defaultValue="99" placeholder="嘿嘿"/>
          </div>
      )
    }

    showData = () => {
      console.log(this['input2'].value)
    }
    showData2 = () => {
      console.log(this['input2'].value)
    }
    showData3 = (e) => {
      console.log(e.target.value)
    }
    saveInput = (currentNode) => {
      this.input2 = currentNode
    }
  }

  ReactDOM.render(<Demo />, document.getElementById('app'))
</script>
</body>
</html>
